package com.zxl.baselib.widget;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.wang.avi.AVLoadingIndicatorView;
import com.zxl.baselib.R;

/**
 * Created by apple on 2019-08-13.
 * description:
 */
public class YCLoadingView extends LinearLayout {
    private AVLoadingIndicatorView mAVLoadingIndicatorView;

    public YCLoadingView(Context context) {
        this(context,null);
    }

    public YCLoadingView(Context context, @Nullable AttributeSet attrs) {
        this(context,attrs,0);
    }

    public YCLoadingView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context);
    }

    private void initView(Context context) {
        View.inflate(context, R.layout.load_view, this);
        mAVLoadingIndicatorView = findViewById(R.id.avi);
    }

    @Override
    public void setVisibility(int visibility) {
        if (visibility == VISIBLE){
            if (null != mAVLoadingIndicatorView){
                mAVLoadingIndicatorView.show();
            }
        }else {
            if (null != mAVLoadingIndicatorView){
                mAVLoadingIndicatorView.hide();
            }
        }
        super.setVisibility(visibility);
    }
}
